<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
  <include file="Public/breadcrumb"/>
  <style type="text/css">
  	/* .table input{display: none;} */
  </style>
  <section class="content">
    <div class="container-fluid">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title"><i class="fa fa-list"></i>店铺促销</h3>
        </div>
        <div class="panel-body">    
		<div class="navbar navbar-default">                    
                <form id="search-form2" class="navbar-form form-inline"  method="get" action="{:U('prom_store_list')}">
                <div class="form-group">
				  
                  <label for="input-order-id" class="control-label">店铺名:</label>
                  <div class="input-group">
                    <input type="text" class="form-control" id="store_name" placeholder="店铺名" value="{$Think.request.store_name}" name="store_name" />
                  </div>
                  
<!--                   <div class="input-group margin">                    
                    <div class="input-group-addon">
                        开店时间<i class="fa fa-calendar"></i>
                    </div>
                       <input type="text" id="start_time" value="{$Think.request.store_time}" name="store_time" class="form-control pull-right">
                  </div> -->                 
                </div>
                <div class="form-group">    
                    <button class="btn btn-primary" id="button-filter search-order" type="submit"><i class="fa fa-search"></i> 筛选</button>    
                </div> 
                </form>
				<span style="color: red;margin-left: 25px;">关闭打折只需将折扣设置为100，或者将时间调整为过期即可。</span>
          </div>
                        
          <div id="ajax_return"> 
                 
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <th class="sorting text-center">店铺id</th>
                                <th class="sorting text-center">店铺名称</th>
                                <th class="sorting text-center">店铺折扣%</th>
								<th class="sorting text-center">产品数量</th>
								<th class="sorting text-center">活动数量</th>
                                <th class="sorting text-center">开始时间</th>
								<th class="sorting text-center">结束时间</th>
                                <th class="sorting text-center">状态</th>
<!--                                <th class="sorting text-center">操作</th> -->
                            </tr>
                            </thead> 
                            <tbody>
                            <volist name="list" id="v">
                                <tr>
                                    <td class="text-center">
                                            {$v.store_id}
                                    </td>
                                    <td class="text-center">
                                        <a href="/index.php/Seller/Admin/login/store_id/{$v[store_id]}" target="_blank">
                                             {$v.store_name}
                                        </a>
                                    </td>
                                    
                                    <td class="text-center" style="color: red;"><!-- <span>{$v.zhekou}</span> -->
										<input type="text" onchange="zhekou_update('{$v.store_id}',this)" size="4" value="{$v.zhekou}" id="zhekou" class="input-sm"></td>
									<td class="text-center">{$v.goods_count}</td>
									<th class="sorting text-center">{$v.prom_count}个</th>
                                    <td class="text-center">
										<input type="text" onchange="zhekou_update('{$v.store_id}',this)" maxlength="10" value='{$v.start_time|date="Y-m-d H:i",###}' id="start_time" class="input-sm" style="width:100%;text-align: center;display: block;"></td>
									<td class="text-center">
										<input type="text" onchange="zhekou_update('{$v.store_id}',this)" maxlength="10" value='{$v.end_time|date="Y-m-d H:i",###}' id="end_time" class="input-sm" style="width: 100%;text-align: center;display: block;"></td>
                                    <td class="text-center">                                         
                                        <if condition="$v[zhekou] eq 100">关闭</if>                                        
                                        <if condition="$v[zhekou] neq 100">开启</if>
                                    </td>                                    
<!--                                    <td class="text-center">
                                        <a href="javascript:" data-toggle="tooltip" rel="{$v.store_id}" class="btn btn-primary" id="pandian" data-original-title="编辑">设置折扣 <i class="fa fa-pencil"></i></a>
                                    </td> -->
                                </tr>
                            </volist>
                            </tbody>
                        </table>
                    </div>
                
                <div class="row">
                    <div class="col-sm-6 text-left"></div>
                    <div class="col-sm-6 text-right">{$show}</div>
                </div>
          
          </div>
        </div>
      </div>
    </div>
    <!-- /.row --> 
  </section>
  <!-- /.content --> 
</div>
<!-- /.content-wrapper --> 
 <script>

function zhekou_update(store_id,obj)
{
 		var zhekou =$(obj).parent().parent().find('#zhekou').val();//折扣值
		var upload = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
		var start_time=$(obj).parent().parent().find('#start_time').val();
		var end_time=$(obj).parent().parent().find('#end_time').val();
		$.post('/index.php/Admin/Promotion/prom_store_list',{store_id:store_id,zhekou:zhekou,action:'zhekou',start_time:start_time,end_time:end_time},function(res){
			layer.close(upload);
			layer.msg('折扣设置成功！', {icon: 1});
		})	
}

 // 删除操作
function del(id)
{
	if(!confirm('确定要删除吗?'))
		return false;		
		$.ajax({
			url:"/index.php?m=Admin&c=Finance&a=delStoreWithdrawals&id="+id,
			success: function(v){	
                            var v =  eval('('+v+')');                                 
                            if(v.hasOwnProperty('status') && (v.status == 1))
                               location.href='{:U('Admin/Finance/store_withdrawals')}';
                            else                                
			        layer.msg(v.msg, {icon: 2,time: 1000}); //alert(v.msg);
			}
		}); 
	 return false;
}
 
$(document).ready(function() {
    $('#start_time,#end_time').daterangepicker({
        startDate: moment().startOf('day'),
        format:"YYYY-MM-DD HH:mm",
        singleDatePicker: true,
        showDropdowns: true,
        showWeekNumbers: true,
        timePicker: true,
        timePickerIncrement: 1,
        timePicker12Hour: false,
        opens: 'left',
        buttonClasses: ['btn btn-default'],
        applyClass: 'btn-small btn-primary',
        cancelClass: 'btn-small',
        locale : {
            applyLabel : '确定',
            cancelLabel : '取消',
            fromLabel : '起始时间',
            toLabel : '结束时间',
            customRangeLabel : '自定义',
            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
            firstDay : 1
        }
    });
	// $(".table #pandian").click(function(){
	// 	if(!confirm('确定要整店促销吗?整店促销后，商家促销产品将全部按整店促销折扣为准。'))
	// 		return false;
			
	// 	var myid=$(this).attr('rel');
	// 	var obj=$(this).parent().parent();
	// 	$(".table input").hide();
	// 	$(".table span").show();
	// 	obj.find('input').show();
	// 	obj.find('span').hide();
		
	// 	obj.find('input').first().val(100);
	// 	obj.find('span').text(100);
	// });
});
</script>
</body>
</html>